﻿using Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Win.Test21.BLL;

namespace Win.Test21.UI
{
    public partial class LoginForm : Form
    {
        private UserInfoBll userInfoBll = new UserInfoBll();
        public LoginForm()
        {
            InitializeComponent();
        }

        private void btn_login_Click(object sender, EventArgs e)
        {
            string username = tbx_username.Text.Trim();
            string password = tbx_password.Text;
            if (username.Length==0 || password.Length==0)
            {
                MessageBox.Show("请输入用户名或密码","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return;
            }
            if (userInfoBll.GetUserInfo(username,Md5Helper.GetMd5(password)))
            {
                Hide();
                Form1 form1 = new Form1();
                form1.Tag = username;
                form1.Show();
            }
            else
            {
                MessageBox.Show("用户名或密码不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btn_quit_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
